package com.jml.task.mapper;

import com.jml.task.entity.CommodityDetails;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;


public interface CommodityDetailsMapper {

    /**
     * 扣库存
     *
     * @return
     */
    @Update("update   commodity_details set stock = stock-1 where id=#{commodityId}")
    int reduceInventory(Long commodityId);

    @Select("select * from  commodity_details where id=#{commodityId}")
    CommodityDetails getCommodityDetails(Long commodityId);

    @Update("update   commodity_details set stock = stock-1 where id=#{commodityId} and stock>0")
    int reduceInventory2(Long commodityId);

}
